package com.fuxin.hanfu.controller;

import com.fuxin.hanfu.domain.Item;
import com.fuxin.hanfu.domain.Message;
import com.fuxin.hanfu.service.MessageService;
import com.fuxin.hanfu.uitls.MyResponse;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController {
   @Resource
    private MessageService messageService;
   //查找
   @GetMapping("/find")
    public List<Message> findList(Message message){
       return messageService.findList(message);
   }

//根据id查询
    @GetMapping("/find/{id}")
    public MyResponse findById(@PathVariable Integer id) {
        return MyResponse.toJson(true, messageService.findById(id));}
//新增
    @PostMapping("/add")
    public Integer insert(@RequestBody Message message) {
        return messageService.insert(message);
    }

//    修改
    @PutMapping("/update/{id}")
    public MyResponse update(@RequestBody Message message) {
        return MyResponse.toJson(true, messageService.update(message));
    }

//    删除
    @DeleteMapping("/delete/{id}")
    public Integer delete(@PathVariable Integer id) {
        return  messageService.delete(id);
    }
}
